package com.veo.dao;

import com.veo.bean.User;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface UserDao {



    @Insert("insert into user(username,address,birthday,sex) values(#{username},#{address},#{birthday},#{sex})")
    int addUser(User user);

    @Update("update user set username = #{username},birthday=#{birthday},address=#{address},sex=#{sex} where id = #{id}")
    int updateUser(User user);

    @Delete("delete from user where id = #{id}")
    int delUser(int id);

    @Select("select * from user where id = #{id}")
    @ResultMap("userMap")
    User findUserById(int id);

    @Select("select * from user")
    @Results(id = "userMap",value = {
            @Result(id = true,column = "id",property = "id"),
            @Result(column = "username",property = "username"),
            @Result(column = "address",property = "address"),
            @Result(column = "birthday",property = "birthday"),
            @Result(column = "sex",property = "sex"),
    })
    List<User> findAllUser();

}
